package cn.tedu.ivos.geofence.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.geofence.pojo.dto.GeofenceParam;
import cn.tedu.ivos.geofence.pojo.dto.GeofenceQuery;
import cn.tedu.ivos.geofence.pojo.entity.Geofence;
import cn.tedu.ivos.geofence.pojo.vo.GeofenceVO;
import cn.tedu.ivos.geofence.service.GeofenceService;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.Jar;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/geofence")
public class GeofenceController {
    @Autowired
    GeofenceService geofenceService;
    @GetMapping("select")
    public JsonResult select(GeofenceQuery geofenceQuery){
        log.debug("查询电子围栏列表 : geofenceQuery={}",geofenceQuery);
        List<GeofenceVO> geofenceVOS = geofenceService.select(geofenceQuery);
        return JsonResult.ok(geofenceVOS);
    }
    @PostMapping("save")
    public JsonResult saveGeo(GeofenceParam geofenceParam){
        log.debug("保存电子围栏: geofenceParam={}",geofenceParam);
        geofenceService.save(geofenceParam);
        return JsonResult.ok();
    }
    @PostMapping("delete/{id}")
    public JsonResult deleteGeo(@PathVariable Long id){
        log.debug("删除电子围栏: id={}",id);
        geofenceService.delete(id);
        return JsonResult.ok();
    }
}
